import { NgModule } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";

import { CookieService, CookieBackendService } from "ngx-cookie";

import {
  ServerModule,
  ServerTransferStateModule
} from "@angular/platform-server";
import { ModuleMapLoaderModule } from "@nguniversal/module-map-ngfactory-loader";

import { AppModule } from "./app.module";
import { AppComponent } from "./app.component";

@NgModule({
  imports: [
    // The AppServerModule should import your AppModule followed
    // by the ServerModule from @angular/platform-server.
    AppModule,
    BrowserModule.withServerTransition({
      appId: "eh"
    }),
    ServerModule,
    ModuleMapLoaderModule,
    ServerTransferStateModule
  ],
  providers: [{ provide: "CookieService", useClass: CookieBackendService }], // <--- CHANGES * * * * *
  // Since the bootstrapped component is not inherited from your
  // imported AppModule, it needs to be repeated here.
  bootstrap: [AppComponent]
})
export class AppServerModule {}
